package com.sa.commons.dao.hiber.inter;

import java.util.List;

import com.sa.commons.dao.hiber.batchUpdate.inter.GenericBatchUpdate;

import com.sa.commons.dao.hiber.query.inter.GenericQuery;
import com.sa.commons.dao.hiber.util.Element;

import com.sa.commons.dao.hiber.OrderType;
import com.sa.commons.exception.DBDataErrorException;
import com.sa.commons.exception.DBErrorException;

/**
 * 
 * @author 黄欣
 * 
 * @param <E>
 * @param <PK>
 */
public interface GenericDaoUtil<E> extends GenericQuery<E>,GenericBatchUpdate<E>{


	/**
	 * 查询全部
	 * 
	 * @return List
	 */
	List<E> findAll()throws DBErrorException,DBDataErrorException;

	/**
	 * 获取全部记录
	 * 
	 * @return
	 */
	long countAll()throws DBErrorException,DBDataErrorException;

	/**
	 * 带分页的查询全部
	 * 
	 * @param firstResult
	 * @param maxResult
	 * @return
	 */
	List<E> findAll(int firstResult, int maxResult)throws DBErrorException,DBDataErrorException;

	/**
	 * 
	 * @param firstResult
	 * @param maxResult
	 * @param orderProperties
	 * 		按照排序的参数
	 * @param types
	 * 		参数排序的类型
	 * @return
	 */
	public List<E> findAll(int firstResult, int maxResult,
			String[] orderProperties, OrderType[] types)throws DBErrorException,DBDataErrorException;


	/**
	 * 获取ID的名称，默认的ID的名称为id
	 * 
	 * @return
	 */
	public String getIdName()throws DBErrorException,DBDataErrorException;

	/**
	 * 设置ID的名称，默认的ID的名称为id
	 * 
	 * @return
	 */
	public void setIdName(String idName)throws DBErrorException,DBDataErrorException;
	/**
	 * 查询满足条件的记录数
	 * @param list 查询条件
	 * @return
	 * @throws DBErrorException
	 * @throws DBDataErrorException
	 */
	public long countEntity(List<Element> list) throws DBErrorException,DBDataErrorException;
	/**
	 * 查询满足条件的记录
	 * @param list 查询条件
	 * @return
	 * @throws DBErrorException
	 * @throws DBDataErrorException
	 */
	public List<E> findEntity(List<Element> list) throws DBErrorException,DBDataErrorException;

	/**
	 * 按分页查找满足的条件的记录
	 * @param list 查询条件
	 * @param firstResult 第一条记录位置
	 * @param maxResult 最多条数
	 * @return
	 * @throws DBErrorException
	 * @throws DBDataErrorException
	 */
	public List<E> findEntity(List<Element> list, int firstResult, int maxResult) throws DBErrorException,DBDataErrorException;
}
